using Castle.ActiveRecord;
using Cooking.Core.DataInterfaces;
using Cooking.Core.Model;
using NHibernate.Expression;

namespace Cooking.Data
{
    public class IngredientDao : IIngredientDao
    {
        public Ingredient FindByName(string name)
        {
            return ActiveRecordMediator<Ingredient>.FindOne(DetachedCriteria
                                                                .For<Ingredient>()
                                                                .Add(Expression.Eq("Name", name)));
        }

        public void Create(Ingredient ingredient)
        {
            ActiveRecordMediator.Create(ingredient);
        }

    }
}